package com.atguigu.dga.governance.task;


import com.atguigu.dga.governance.service.MainAssessService;
import com.atguigu.dga.meta.service.TableMetaInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@Slf4j
public class AssessTask {

    @Value("${assess.schema-name}")
    String schemaName;

    @Autowired
    TableMetaInfoService tableMetaInfoService;

    @Autowired
    MainAssessService mainAssessService;

    @Scheduled(cron = "0 50 11 * * *")
    public  void doTask() throws Exception {

        String assessDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd");
        assessDate="2023-05-02";

        log.debug("1123123");
        tableMetaInfoService.initTableMetaInfo(assessDate,schemaName);
        mainAssessService.mainAssess(assessDate);


    }
}
